package com.bdqn.t382.factory;

import com.bdqn.t382.dao.NewsDao;
import com.bdqn.t382.dao.imp.NewsDaoImpl;

public class SimpleDaoFactory {
    /**
     * 创建 NewsDao 实例的工厂方法
     */
    public static NewsDao getInstance(String key) {
        // return new NewsDaoImpl();
        switch (key) {
            case "mysql":
                return new NewsDaoImpl();
            case "oracle":
                return new NewsDaoImpl();
            case "redis":
                return new NewsDaoImpl();
            default:
                throw new RuntimeException("无效的数据库类型：" + key
                        + " ，DAO 获取失败");
        }
    }
}
